package com.bankcomm.ui;

import org.keplerproject.luajava.LuaException;
import com.bankcomm.R;
import com.bankcomm.ui.views.LPBottomBar;
import com.bankcomm.util.LPUtils;
import com.rytong.tools.utils.LPToastUtil;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

public class BCMBranchBankActivity extends EMPView implements OnClickListener {
	private FrameLayout mainLayout;
	private LinearLayout contentView;
	private RelativeLayout topLayout;

	@Override
	public void onCreate(Bundle savedInstanceState) {
		contentView = (LinearLayout) LayoutInflater.from(this).inflate(
				R.layout.bcm_branch_bank_layout, null);
		Button backBtn = (Button) contentView.findViewById(R.id.backtitle);
		Button mainHomeBtn = (Button) contentView.findViewById(R.id.hometitle);
		LPBottomBar bottomBar = (LPBottomBar) contentView.findViewById(R.id.bottom_bar);
		bottomBar.setSelectTab(1);

		mainLayout = (FrameLayout) contentView.findViewById(R.id.content_view);
		topLayout = (RelativeLayout) findViewById(R.id.linearLayout1);
		LPUtils.scaledTHeightRel(topLayout);
		
		LPUtils.setTitleButtonWH(backBtn);
		LPUtils.setTitleButtonWH(mainHomeBtn);
		
		backBtn.setOnClickListener(this);
		mainHomeBtn.setOnClickListener(this);
		super.onCreate(savedInstanceState);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
	}

	@Override
	public void setContentView(View view) {
		mainLayout.removeAllViews();
		mainLayout.addView(view);
		super.setContentView(contentView);
	}

	@Override
	public void onClick(View arg0) {
		int id = arg0.getId();
		switch (id) {
		case R.id.backtitle:
			try {
				keyBackPress();
			} catch (LuaException e) {
				e.printStackTrace();
			}
			break;

		case R.id.hometitle:
			finish();
			break;
		}

	}
	@Override
	public void finish() {
		LPToastUtil.getInstance().isBranchBank = false;
		LPToastUtil.getInstance().isHasStyle = false;
		super.finish();
	}
}
